fix: address rust tutorial issues from #191#192
Merged
Conversation
… wording Reorder oracle_data_query.rs to compile the oracle reader contract and tx script BEFORE the live Pragma storage walk, so a dead Pragma deployment no longer blocks local verification of the template substitution and MASM assembly path. Add three log lines (template substituted, component compiled, tx_script compiled) so the verification script can classify oracle import failure as TEMP PASS when the local compile path is healthy. Add oracle_tutorial.md to docs/src/lib.rs for doctesting alongside the other tutorial pages. Strengthen the Pragma callout in oracle_tutorial.md: after Pragma redeploys, the oracle account ID and GET_MEDIAN_PROC_HASH constant must be re-verified; do not assume either survives a redeploy unchanged. Apply prettier-formatting fixes to oracle_tutorial.md (italics syntax and three fenced-block language hints).
Reorder the doc snippet in oracle_tutorial.md to match the runnable oracle_data_query.rs: build and locally compile the oracle reader contract and tx script BEFORE walking Pragma's storage, with the same three progress println lines (template substituted, component compiled, tx_script compiled). The doc and bin now read identically through the local-compile path, so the tutorial accurately reflects how a dead Pragma deployment surfaces (only the storage walk fails). Replace stale 'trading_pair requirement' wording with 'pair_word' to match the actual function-signature argument.
partylikeits1983
approved these changes
Apr 29, 2026
Collaborator
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks great! Thanks for doing this.
Leaving a conditional approval, I'd remove all the comment references to that VM issue/PR, its irrelevant context for a future reader / consumer of the tutorials & examples. There are more references to vm #2778 than what I listed below
| // Compile the account code into `AccountComponent` with one storage slot. | ||
| // Using `client.code_builder()` makes the assembler share the client's | ||
| // persisted source manager, which keeps debug spans coherent for any | ||
| // libraries that link against this code later (see miden-vm#2778). |
Collaborator
There was a problem hiding this comment.
Could you refactor this comment to not reference the VM PR?
|
|
||
| // Compile the script with the counter contract code linked as a dynamic | ||
| // module on the same `CodeBuilder`. This shares the client's source | ||
| // manager between parsing and assembly, which is what miden-vm#2778 |
| // Compile the transaction script with the library. | ||
| // Compile the transaction script with the account code linked as a | ||
| // module on the same `CodeBuilder` chain (avoids the source-span | ||
| // mismatch from miden-vm#2778). |
|
|
||
| // Link the counter contract code into the same `CodeBuilder` chain that | ||
| // compiles the script, so the assembler shares the client's persisted | ||
| // source manager (avoids the source-span mismatch from miden-vm#2778). |
|
|
||
| // Compile the note script with the counter contract library | ||
| // Compile the note script with the counter contract code linked as a | ||
| // module on the same `CodeBuilder` chain (avoids miden-vm#2778). |
|
|
||
| // Link the counter contract code into the same `CodeBuilder` chain that | ||
| // compiles the script, so the assembler shares the client's persisted | ||
| // source manager (avoids the source-span mismatch from miden-vm#2778). |
|
|
||
| // Compile the note script with the counter contract library | ||
| // Compile the note script with the counter contract code linked as a | ||
| // module on the same `CodeBuilder` chain (avoids miden-vm#2778). |
|
|
||
| // Link the counter contract code into the same `CodeBuilder` chain that | ||
| // compiles the script, so the assembler shares the client's persisted | ||
| // source manager (avoids the source-span mismatch from miden-vm#2778). |
|
|
||
| // Compile the note script with the counter contract library | ||
| // Compile the note script with the counter contract code linked as a | ||
| // module on the same `CodeBuilder` chain (avoids miden-vm#2778). |
|
|
||
| // Compile the script against the counter contract code via a single | ||
| // `CodeBuilder` chain so the assembler shares the client's persisted | ||
| // source manager (avoids the source-span mismatch from miden-vm#2778). |
Address partylikeits1983 review on PR #192: drop `miden-vm#2778` and related internal-VM context from future-facing tutorial and example comments. Behavior is unchanged (the `client.code_builder() .with_linked_module(...)` path is preserved); only the rationale text in comments is reduced to the tutorial-relevant local fact (the contract code is linked into the same `CodeBuilder` chain that compiles the script or note). Affected: 6 rust-client binaries and 6 mirrored tutorial doc snippets.
Collaborator
Author
|
Requesting re-review from @partylikeits1983 |
Brings in: - #184 fix: refactor miden-bank tutorial test flow and init guard progression - #196 docs: fix duplicate 'a' in oracle tutorial Conflict in docs/src/rust-client/oracle_tutorial.md: both sides applied the #196 typo fix (removing the duplicate 'a'). HEAD additionally ends the sentence with a period. Kept HEAD's version (typo fix + period) so both intents are preserved.
Brings in: - #201 fix: update oracle tutorial for Pragma's v14 oracle deployment Conflicts in the three oracle files (docs/src/rust-client/oracle_tutorial.md, masm/accounts/oracle_reader.masm, rust-client/src/bin/oracle_data_query.rs): resolved by taking main's #201 version, which supersedes this PR's earlier oracle work with values verified against Pragma's live v14 deployment. The PR's other changes (create_library removal, include_str! path fixes, @note_script v0.14.5 migration, dependency cleanup) are preserved unchanged. oracle_tutorial.md additionally re-tags three code blocks that main left untagged (directory tree and sample output -> text, run command -> bash). This PR wires oracle_tutorial.md into the docs doctest harness (docs/src/lib.rs); without the tags those blocks compile as Rust doctests and fail. The tags restore green doc-tests and change no oracle content.
partylikeits1983
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes the issues raised in #191 across the rust-client tutorials: removes the cwd-dependent MASM-loading and per-binary
create_librarypattern, migrates the tutorial note scripts to the v0.14.5@note_scriptform, bumps both lockfiles to0.14.5, and drops unused dependencies. The oracle tutorial is not reworked here — #201 already landed the live Pragma v14 oracle implementation onmain, so this branch keeps #201's oracle code verbatim and only retags three oracle-tutorial code fences so the file can join the docs doctest suite (see the Oracle Tutorial Note).Key Changes
create_libraryremoval (non-oracle tutorials). Drops the per-binarycreate_libraryhelper and compiles MASM through a singleclient.code_builder().with_linked_module(...)chain instead, avoiding the cross-source-manager handoff behindinvalid source span. Applied across the counter-contract, FPI, mapping, and note-creation examples and their docs.include_str!path fixes (non-oracle tutorials). Replaces cwd-relativePath::new("../masm/...")loading (which broke when users ran from their own project root) withinclude_str!, resolved at compile time relative to the source file.@note_scriptv0.14.5 migration. Converts the three tutorial note scripts —masm/notes/{hash_preimage_note,iterative_output_note,network_increment_note}.masm— to the@note_script pub proc mainlibrary form now required bymiden-protocol@0.14.5.rust-client/Cargo.lockanddocs/Cargo.locktomiden-{client,client-sqlite-store,protocol,standards}@0.14.5, and removes the unusedserde,serde_json, andrand_chachadependencies (and their stale tutorial[dependencies]snippets) from bothCargo.tomlfiles.docs/src/rust-client/oracle_tutorial.mdtodocs/src/lib.rsso its code blocks are exercised by the docs doctest suite.Oracle Tutorial Note
The live Pragma oracle implementation now lives on
mainvia #201, which updatedoracle_data_query.rs,oracle_reader.masm, and the oracle tutorial prose for Pragma's deployed v0.14 oracle. This branch merges #201 and takes its versions as-is:masm/accounts/oracle_reader.masmandrust-client/src/bin/oracle_data_query.rsare byte-identical tomain— no diff.docs/src/rust-client/oracle_tutorial.md's only change versusmainis retagging three previously-untagged code fences so they are not compiled as Rust once the file is part of the doctest suite: the directory tree →text, the run command →bash, and the sample program output →text.Verification
doc-tests,format-markdown,Build Documentation,Analyze (actions),Analyze (javascript-typescript), andCodeQLall passing;mergeStateStatusisCLEAN.cargo check --lockedinrust-client/: passed.cargo test --doc --lockedindocs/: 17 passed, 0 failed, 16 ignored.Out of Scope
main(fix: update oracle tutorial for Pragma's v14 oracle deployment #201) exactly; the sole oracle-tutorial change is the three doctest code-fence tags described above.